#!/user/bin/env python3
# -*- coding: utf-8 -*-
"""
--------------------------------------
    Author:     JiChao_Song
    Date  :     2021/12/23 10:36
    Desc  :
--------------------------------------
"""
from typing import Callable, Any, Optional

from faker import Faker

from common.utils.idCard_utils import ssn

FakerUtils = Faker('zh_cn')
from functools import wraps

global_methods = dict()


def method_collect(name: Optional[str] = None
) -> Callable[..., Any]:
    def decorator(func):
        global_methods[name or func.__name__] = dict(name = func.__name__, desc = func.__doc__)
        return func

    return decorator


@method_collect()
def random_name():
    """
    随机新买
    :return:
    """
    return FakerUtils.name()


@method_collect()
def random_phone():
    """
    随机手机号
    :return:
    """
    return FakerUtils.phone_number()


@method_collect()
def random_ssn(min_age: int = 18, max_age: int = 40, gender: int = 1):
    """
    随机身份证号码
    :param min_age: 最小年龄
    :param max_age: 最大年龄
    :param gender: 性别
    :return:
    """
    return ssn(min_age = min_age, max_age = max_age, gender = gender)


@method_collect()
def random_paragraph():
    """
    随机段鸾
    :return:
    """
    return FakerUtils.paragraph()


@method_collect()
def random_password(
        length: int = 10,
        special_chars: bool = True,
        digits: bool = False,
        upper_case: bool = True,
        lower_case: bool = False,
):
    """
    生成随机密码
    :param: length：密码长度
    :param: special_chars：是否能使用特殊字符
    :param: digits：是否包含数字
    :param: upper_case：是否包含大写字母
    :param: lower_case：是否包含小写字母
    :return:
    """

    return FakerUtils.password(
        length = length,
        special_chars = special_chars,
        digits = digits,
        upper_case = upper_case,
        lower_case = lower_case
    )


@method_collect()
def random_company():
    """
    随机公司名称
    :return:
    """

    return FakerUtils.company()


@method_collect()
def random_job():
    """
    随机岗位
    :return:
    """
    return FakerUtils.job()


@method_collect()
def random_address():
    """
    随机地址
    :return:
    """
    return FakerUtils.address()
